import datetime
from typing import Union

from pydantic import BaseModel, Field


class ToolkitCallSchema(BaseModel):
    name: str
    args: Union[list, None]
    content: Union[str, None]


class ToolkitSchema(BaseModel):
    name: str
    type: int
    tags: Union[str, None]
    args: Union[str, None]
    desc: Union[str, None]
    content: Union[str, None]
    sort: Union[int, None]
    username: Union[int, None]


class ToolkitLogSchema(BaseModel):
    toolkit_id: str
    toolkit_name: str
    create_time: datetime.datetime
    username: Union[str, None]
    status: int
    log: str


class ToolkitSearchSchema(BaseModel):
    _id: Union[int, None]
    name: Union[str, None]
    desc: Union[str, None]
    type: Union[str, None]


class ToolkitUpdateSchema(BaseModel):
    id: str
    name: Union[str, None]
    type: Union[int, None]
    executor: Union[str, None]
    exec_user: Union[str, None]
    workspace: Union[str, None]
    tags: Union[str, None]
    args: Union[list, None]
    content: Union[str, None]
    desc: Union[str, None]
    sort: Union[int, None]


class ToolkitDeleteSchema(BaseModel):
    id_: str


class ToolkitDebugSchema(BaseModel):
    id: str
    exec_user: Union[str, None]
    workspace: Union[str, None]
    args: Union[dict, None]
    target: Union[dict, None]
    content: Union[str, None]


class ToolkitDebugLogSchema(BaseModel):
    id_: str
    run_id: str
    seek: Union[int, None]


class ToolkitDiscontinueSchema(BaseModel):
    run_id: str

class ToolkitSortSchema(BaseModel):
    ids: list

class CacheSchema(BaseModel):
    key: str
    data: dict
